<?php 

defined('_JEXEC') or die;

$document =& JFactory::getDocument();
$document->addStyleSheet('modules/mod_sevent_lastevents/assets/stylesheets/default.css');

$is_pagination = $params->get('pagination');

if($is_pagination)
{
	$document->addScript('modules/mod_sevent_lastevents/assets/js/virtualpaginate.js');
	$events_per_page = $params->get('number_of_events_per_page');
}

if (isset($list[0]))
{
	foreach ($list as $event)
	{
		echo '<div class="lastevents_event lastsevents_virtualpage">';
		echo '<h1 class="lastevents_title">'. $event->event_type .'</h1>';
		
		$event_arr = get_object_vars($event);
		$event_arr = array_values($event_arr);
		for($i = 1; $i < count($event_arr); ++$i)
		{
			echo '<p class="lastevents_info">'.$event_arr[$i].'</p>';
		}
			
		echo '<div class="lastevents_line"></div>';
		echo '</div>';
	} 
	
	?>
	<!-- Pagination DIV for Demo 1 -->
	<div id="lastsevents_paginate" class="paginationstyle">
	<a href="#" rel="previous">Prev</a> <span class="flatview"></span> <a href="#" rel="next">Next</a>
	</div>
	
	<!-- Initialize pagination class -->
	<script type="text/javascript">
	
	var gallery=new virtualpaginate({
		piececlass: "lastsevents_virtualpage", //class of container for each piece of content
		piececontainer: 'div', //container element type (ie: "div", "p" etc)
		pieces_per_page: <?php echo $events_per_page; ?>, //Pieces of content to show per page (1=1 piece, 2=2 pieces etc)
		defaultpage: 0, //Default page selected (0=1st page, 1=2nd page etc). Persistence if enabled overrides this setting.
		wraparound: false,
		persist: true //Remember last viewed page and recall it when user returns within a browser session?
	})
	
	gallery.buildpagination(["lastsevents_paginate"])

</script>
<?php 	
} 
else 
{
	echo '<div class="lastevents_event">';
	echo $params->get('no_event_message');
	echo '</div>';
}		

?>


